#include "GameMenu.h"
#include <iostream>

using namespace std;
//Constructor
CGameMenu::CGameMenu(void)
:FrameTime(0.0f)
,MenuType(0)
,MainMenuButtonType(0)
,CharacterButtonType(0)
,SettingButtonType(0)
,LobbyButtonType(0)
,MissionDifficultyButtonType(0)
,MissionButtonType(0)
,ArrowKey_x(0)
,ArrowKey_y(0)
,ToggleUpButton(false)
,ToggleDownButton(false)
,ToggleLeftButton(false)
,ToggleRightButton(false)
,LoadCharacterAndLobbyTexture(false)
,LoadLobbyTexture(false)
,LoadMissionTexture(false)
,LoadSettingTexture(false)
,LoadAchievementMenuTexture(false)
,LoadCreditsTexture(false)
,BGM(true)
,Menu_Animation_x(0)
,Menu_Animation_y(0)
,VibrateAnimation(false)
,PickChar_Animation_x(0)
,PickChar_Animation_y(0)
,PickCharWeapon_Animation_x(0)
,PickCharWeapon_Animation_y(0)
,VibrateAnimationTwo(false)
,CheckWeapon(false)
{
	ButtonTexture = new TextureImage[2];
	LoadTGA(&ButtonTexture[0], "images/ArrowKey.tga");
	LoadTGA(&ButtonTexture[1], "images/ArrowKeyUp.tga");

	//Background
	BackgroundTexture = new TextureImage[3];
	LoadTGA(&BackgroundTexture[0],	"images/background.tga");
	LoadTGA(&BackgroundTexture[1],	"images/Title.tga");
	LoadTGA(&BackgroundTexture[2],	"images/Loading.tga");
	
	//Main Menu
	MainMenuTexture = new TextureImage[6];
	LoadTGA(&MainMenuTexture[0],	"images/MainMenu/NewGame.tga");
	LoadTGA(&MainMenuTexture[1],	"images/MainMenu/Load.tga");
	LoadTGA(&MainMenuTexture[2],	"images/MainMenu/Setting.tga");
	LoadTGA(&MainMenuTexture[3],	"images/MainMenu/Achievement.tga");
	LoadTGA(&MainMenuTexture[4],	"images/MainMenu/Credits.tga");
	LoadTGA(&MainMenuTexture[5],	"images/MainMenu/Exit.tga");

	//Character menu
	CharacterButtonTexture = new TextureImage[6];

	// LOBBY MENU
	LobbyTexture = new TextureImage[20];

	// Mission Menu
	MissionTexture = new TextureImage[16];

	//Settings menu
	SettingsMenuTexture = new TextureImage[4];

	//Achievement menu
	AchievementsMenuTexture = new TextureImage[2];

	//Credits menu
	CreditsMenuTexture = new TextureImage[1];

	Achievement_font.init("Test.ttf", 20);
}

//Destructor
CGameMenu::~CGameMenu(void)
{
	delete [] ButtonTexture;
	delete [] BackgroundTexture;
	delete [] MainMenuTexture;
	delete [] CharacterButtonTexture;
	delete [] LobbyTexture;
	delete [] MissionTexture;
	delete [] SettingsMenuTexture;
	delete [] AchievementsMenuTexture;
	delete [] CreditsMenuTexture;
}

/*****************************
--------- DRAW MENUS ---------
******************************/
//Render Menus
void CGameMenu::RenderMenus(float FrameTime)
{
	// Frame Independent Movement
	this->FrameTime = FrameTime;

	//Main Menu
	if(MenuType == CGameMenu::MAIN_MENU)
	{
		DrawMainMenu();
		DrawMainMenuButton();
		DrawMenuKey();
	}

	else if (MenuType == CGameMenu::SPLASH_SCREEN_MENU)
	{
		DrawSplashScreenMenu();
			
		if ( MainMenuButtonType == LOAD_BUTTON )
			MenuType = CGameMenu::LOBBY_MENU;
		else
			MenuType = CGameMenu::CHARACTER_MENU;
	}
	else if (MenuType == CGameMenu::CHARACTER_MENU)
	{
		if(!LoadCharacterAndLobbyTexture)
		{
			LoadTGA(&CharacterButtonTexture[0],	"images/Lobby/SwordAndShield_Lobby1.tga");
			LoadTGA(&CharacterButtonTexture[1],	"images/Lobby/GreatSword_Lobby1.tga");
			LoadTGA(&CharacterButtonTexture[2],	"images/Lobby/DualSword_Lobby1.tga");
			LoadTGA(&CharacterButtonTexture[3],	"images/Lobby/SwordAndShield_Lobby2.tga");
			LoadTGA(&CharacterButtonTexture[4],	"images/Lobby/GreatSword_Lobby2.tga");
			LoadTGA(&CharacterButtonTexture[5],	"images/Lobby/DualSword_Lobby2.tga");
			LoadTGA(&LobbyTexture[11],			"images/Lobby/Choose_Your_Weapon.tga");
			LoadTGA(&LobbyTexture[12],			"images/Lobby/DualSword.tga");
			LoadTGA(&LobbyTexture[13],			"images/Lobby/Great_Sword.tga");
			LoadTGA(&LobbyTexture[14],			"images/Lobby/Sword_And_Shield.tga");

			LoadCharacterAndLobbyTexture = true;
		}

		DrawCharacterMenu();
		DrawChooseCharacterButton();
	}

	//Setting
	else if (MenuType == CGameMenu::SETTING_MENU)
	{
		if(!LoadSettingTexture)
		{
			LoadTGA(&SettingsMenuTexture[0],	"images/Settings/Settings.tga");
			LoadTGA(&SettingsMenuTexture[1],	"images/Settings/Sounds.tga");
			LoadTGA(&SettingsMenuTexture[2],	"images/Settings/On.tga");
			LoadTGA(&SettingsMenuTexture[3],	"images/Settings/Off.tga");

			LoadSettingTexture = true;
		}
	
		DrawSettingMenu();
		DrawSettingButton();
		DrawSettingKey();
	}
	
	//Achievement
	else if (MenuType == CGameMenu::ACHIEVEMENT_MENU)
	{
		if(!LoadAchievementMenuTexture)
		{
			LoadTGA(&AchievementsMenuTexture[0],	"images/Achievements/Achievements.tga");
			LoadTGA(&AchievementsMenuTexture[1],	"images/Lobby/Frame.tga");

			LoadAchievementMenuTexture = true;
		}

		DrawAchievementMenu();
	}
	
	//Credits
	//else if (MenuType == CGameMenu::CREDIT_MENU)
	//{
	//	if(!LoadCreditsTexture)
	//	{
	//		LoadTGA(&CreditsMenuTexture[0],	"images/Credits/Credits.tga");

	//		LoadCreditsTexture = true;
	//	}

	//	DrawCreditsMenu();
	//}

	//Lobby
	else if (MenuType == CGameMenu::LOBBY_MENU)
	{
		if(!LoadLobbyTexture)
		{
			LoadTGA(&LobbyTexture[SWORD_AND_SHIELD_SHOP_BUTTON],	"images/Lobby/SwordAndShield_Lobby1.tga");
			LoadTGA(&LobbyTexture[GREAT_SWORD_SHOP_BUTTON],			"images/Lobby/GreatSword_Lobby1.tga");
			LoadTGA(&LobbyTexture[DUAL_SWORD_SHOP_BUTTON],			"images/Lobby/DualSword_Lobby1.tga");
			LoadTGA(&LobbyTexture[POTION_BUTTON],					"images/Lobby/Potion_Lobby1.tga");
			LoadTGA(&LobbyTexture[4],								"images/Lobby/Background_Lobby.tga");
			LoadTGA(&LobbyTexture[5],								"images/Lobby/LeftArrow.tga");
			LoadTGA(&LobbyTexture[6],								"images/Lobby/RightArrow.tga");
			LoadTGA(&LobbyTexture[7],								"images/Lobby/Upgrade.tga");
			LoadTGA(&LobbyTexture[8],								"images/Lobby/Buy.tga");
			LoadTGA(&LobbyTexture[9],								"images/Lobby/Q.tga");
			LoadTGA(&LobbyTexture[10],								"images/Lobby/Shop.tga");
			
			LoadTGA(&LobbyTexture[15],								"images/Lobby/Frame.tga");

			LoadTGA(&LobbyTexture[16],								"images/Item_BrokenSword.tga");
			LoadTGA(&LobbyTexture[17],								"images/Item_BrokenBow.tga");
			LoadTGA(&LobbyTexture[18],								"images/Item_Bag.tga");
			LoadTGA(&LobbyTexture[19],								"images/Lobby/Potion.tga");

			LoadLobbyTexture = true;
		}

		DrawLobbyMenu();
		DrawLobbyButton();
	}

	//Mission
	else if (MenuType == CGameMenu::MISSION_MENU)
	{
		if(!LoadMissionTexture)
		{
			LoadTGA(&MissionTexture[0],	"images/Mission/Easy.tga");
			LoadTGA(&MissionTexture[1],	"images/Mission/Normal.tga");
			LoadTGA(&MissionTexture[2],	"images/Mission/Hard.tga");
			LoadTGA(&MissionTexture[3],	"images/Mission/Quest.tga");
			LoadTGA(&MissionTexture[4],	"images/Mission/EasyLevel_1.tga");
			LoadTGA(&MissionTexture[5],	"images/Mission/EasyLevel_2.tga");
			LoadTGA(&MissionTexture[6],	"images/Mission/EasyLevel_3.tga");
			LoadTGA(&MissionTexture[7],	"images/Mission/Normal_one.tga");
			LoadTGA(&MissionTexture[8],	"images/Mission/Normal_Two.tga");
			LoadTGA(&MissionTexture[9],	"images/Mission/Normal_three.tga");

			LoadTGA(&MissionTexture[10],"images/Mission/Collect.tga");
			LoadTGA(&MissionTexture[11],"images/Mission/Hunt.tga");
			LoadTGA(&MissionTexture[12],"images/Mission/Protect.tga");

			LoadTGA(&MissionTexture[13],	"images/Mission/HardLevel_1.tga");
			LoadTGA(&MissionTexture[14],	"images/Mission/HardLevel_2.tga");
			LoadTGA(&MissionTexture[15],	"images/Mission/HardLevel_3.tga");

			LoadMissionTexture = true;
		}

		DrawMissionMenu();
		DrawCharKey(); 
		DrawMissonButton();
	}
}

//Draw Main Menu
void CGameMenu::DrawMainMenu(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );;

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Title
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[1].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(200, 10);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(200, 150);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 150);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 10);		//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}

//Draw Splash Screen Menu
void CGameMenu::DrawSplashScreenMenu(void)
{
	MenuButtonAnimation();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Loading...
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[2].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(600 + PickCharWeapon_Animation_x, 500);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(600 + PickCharWeapon_Animation_x, 600);	//Top left
			glTexCoord2f(1,0); glVertex2f(800 + PickCharWeapon_Animation_x, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800 + PickCharWeapon_Animation_x, 500);	//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
//Draw Choose Character Menu
void CGameMenu::DrawCharacterMenu(void)
{
	MenuButtonAnimation();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Title
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[1].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(200, 10);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(200, 150);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 150);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 10);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Choose your weapon
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[11].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(100 + PickChar_Animation_x, 200 + PickChar_Animation_x);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(100 + PickChar_Animation_x, 275 + PickChar_Animation_x);	//Top left
			glTexCoord2f(1,0); glVertex2f(700 + PickChar_Animation_x, 275 + PickChar_Animation_x);	//Top right
			glTexCoord2f(1,1); glVertex2f(700 + PickChar_Animation_x, 200 + PickChar_Animation_x);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Dual Sword
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[12].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(550 + PickCharWeapon_Animation_x, 515);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(550 + PickCharWeapon_Animation_x, 565);	//Top left
			glTexCoord2f(1,0); glVertex2f(750 + PickCharWeapon_Animation_x, 565);	//Top right
			glTexCoord2f(1,1); glVertex2f(750 + PickCharWeapon_Animation_x, 515);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Great Sword
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[13].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(300 + PickCharWeapon_Animation_x, 515);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(300 + PickCharWeapon_Animation_x, 565);	//Top left
			glTexCoord2f(1,0); glVertex2f(500 + PickCharWeapon_Animation_x, 565);	//Top right
			glTexCoord2f(1,1); glVertex2f(500 + PickCharWeapon_Animation_x, 515);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Sword and Shield
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[14].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(50 + PickCharWeapon_Animation_x, 515);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(50 + PickCharWeapon_Animation_x, 565);	//Top left
			glTexCoord2f(1,0); glVertex2f(250 + PickCharWeapon_Animation_x, 565);	//Top right
			glTexCoord2f(1,1); glVertex2f(250 + PickCharWeapon_Animation_x, 515);	//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}

//Draw Setting Menu
void CGameMenu::DrawSettingMenu(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Title
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, SettingsMenuTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(200, 10);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(200, 150);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 150);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 10);		//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
//Draw Achievement Menu
void CGameMenu::DrawAchievementMenu(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Title
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, AchievementsMenuTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(200, 10);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(200, 150);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 150);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 10);		//Bottom right
		glEnd();
	glPopMatrix ();

	for(int i = 1; i < 4; i++)
	{
		for(int j = 1; j < 3; j++)
		{
		glPushMatrix ();
			glColor3f(0.5f, 0.5f, 0.5f);
			glBindTexture(GL_TEXTURE_2D, AchievementsMenuTexture[1].texID);
			glBegin( GL_QUADS );
				glTexCoord2f(0,1); glVertex2f(75 + ((j-1) * 350)		, 150 + (i*75) + ((i-1)*50)	);		//Bottom left
				glTexCoord2f(0,0); glVertex2f(75 + ((j-1) * 350)		, 150 + ((i-1)*125)			);		//Top left
				glTexCoord2f(1,0); glVertex2f(75 + (j*300) + ((j-1)*50), 150 +	((i-1)*125)			);		//Top right
				glTexCoord2f(1,1); glVertex2f(75 + (j*300)	+ ((j-1)*50), 150 + (i*75) + ((i-1)*50)	);		//Bottom right
			glEnd();
		glPopMatrix ();
		}
	}

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture

	if(AchGetJump())
		glColor3f(1.0f, 1.0f, 1.0f);
	else
		glColor3f(0.0f, 0.0f, 0.0f);
	freetype::print(Achievement_font, 80, 600 - 200, "Jumped 5 Times");

	if(AchGetJump50())
		glColor3f(1.0f, 1.0f, 1.0f);
	else
		glColor3f(0.0f, 0.0f, 0.0f);
	freetype::print(Achievement_font, 440, 600 - 200, "Jumped 50 Times");

	if(AchGetEnemiesKilled())
		glColor3f(1.0f, 1.0f, 1.0f);
	else
		glColor3f(0.0f, 0.0f, 0.0f);
	freetype::print(Achievement_font, 80, 600 - 325, "Killed 5 Enemies");

	if(AchGetEnemiesKilled20())
		glColor3f(1.0f, 1.0f, 1.0f);
	else
		glColor3f(0.0f, 0.0f, 0.0f);
	freetype::print(Achievement_font, 440, 600 - 325, "Killed 20 Enemies");

	if(AchGetItemGet10())
		glColor3f(1.0f, 1.0f, 1.0f);
	else
		glColor3f(0.0f, 0.0f, 0.0f);
	freetype::print(Achievement_font, 80, 600 - 450, "Collected 10 Items");

	if(AchGetItemGet20())
		glColor3f(1.0f, 1.0f, 1.0f);
	else
		glColor3f(0.0f, 0.0f, 0.0f);
	freetype::print(Achievement_font, 440, 600 - 450, "Collected 20 Items");
}
//Draw Credits Menu
void CGameMenu::DrawCreditsMenu(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Title
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, CreditsMenuTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(200, 10);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(200, 150);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 150);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 10);		//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
//Draw Lobby Menu
void CGameMenu::DrawLobbyMenu(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[4].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Shop
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[10].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(250, 0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(250, 150);	//Top left
			glTexCoord2f(1,0); glVertex2f(500, 150);	//Top right
			glTexCoord2f(1,1); glVertex2f(500, 0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Description Board
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[15].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(550, 150);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(550, 400);	//Top left
			glTexCoord2f(1,0); glVertex2f(750, 400);	//Top right
			glTexCoord2f(1,1); glVertex2f(750, 150);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Upgrade Board
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[15].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(100, 150);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(100, 400);	//Top left
			glTexCoord2f(1,0); glVertex2f(500, 400);	//Top right
			glTexCoord2f(1,1); glVertex2f(500, 150);	//Bottom right
		glEnd();
	glPopMatrix ();

	if (LobbyButtonType != CGameMenu::POTION_BUTTON)
	{
		//Material required
		glPushMatrix ();
			glColor3f(1.0f, 1.0f, 1.0f);
			if(LobbyButtonType == CGameMenu::SWORD_AND_SHIELD_SHOP_BUTTON)
			{
				glBindTexture(GL_TEXTURE_2D, LobbyTexture[16].texID);
			}
			else if(LobbyButtonType == CGameMenu::GREAT_SWORD_SHOP_BUTTON)
			{
				glBindTexture(GL_TEXTURE_2D, LobbyTexture[17].texID);
			}
			else if (LobbyButtonType == CGameMenu::DUAL_SWORD_SHOP_BUTTON)
			{
				glBindTexture(GL_TEXTURE_2D, LobbyTexture[18].texID);
			}
			
			glBegin( GL_QUADS );
				glTexCoord2f(0,1); glVertex2f(200, 240);	//Bottom left
				glTexCoord2f(0,0); glVertex2f(200, 350);	//Top left
				glTexCoord2f(1,0); glVertex2f(400, 350);	//Top right
				glTexCoord2f(1,1); glVertex2f(400, 240);	//Bottom right
			glEnd();
		glPopMatrix ();
	}

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
//Draw Mission Menu
void CGameMenu::DrawMissionMenu(void)
{
	MenuButtonAnimation();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[4].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Title
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MissionTexture[3].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(300, 10);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(300, 150);	//Top left
			glTexCoord2f(1,0); glVertex2f(500, 150);	//Top right
			glTexCoord2f(1,1); glVertex2f(500, 10);		//Bottom right
		glEnd();
	glPopMatrix ();

	//Collect
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MissionTexture[10].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(90 + Menu_Animation_x, 165);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(90 + Menu_Animation_x, 215);	//Top left
			glTexCoord2f(1,0); glVertex2f(210 + Menu_Animation_x, 215);	//Top right
			glTexCoord2f(1,1); glVertex2f(210 + Menu_Animation_x, 165);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Hunt
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MissionTexture[11].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(350 + Menu_Animation_x, 165);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(350 + Menu_Animation_x, 215);	//Top left
			glTexCoord2f(1,0); glVertex2f(450 + Menu_Animation_x, 215);	//Top right
			glTexCoord2f(1,1); glVertex2f(450 + Menu_Animation_x, 165);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Protect
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MissionTexture[12].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(590 + Menu_Animation_x, 165);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(590 + Menu_Animation_x, 215);	//Top left
			glTexCoord2f(1,0); glVertex2f(710 + Menu_Animation_x, 215);	//Top right
			glTexCoord2f(1,1); glVertex2f(710 + Menu_Animation_x, 165);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Easy/Normal/Hard
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		if(MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
		{
			glBindTexture(GL_TEXTURE_2D, MissionTexture[0].texID);
		}
		else if(MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
		{
			glBindTexture(GL_TEXTURE_2D, MissionTexture[1].texID);
		}
		else if(MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
		{
			glBindTexture(GL_TEXTURE_2D, MissionTexture[2].texID);
		}
		
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(600, 500);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(600, 600);	//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, 500);	//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
//Draw Easy Level Menu
void CGameMenu::DrawEasyMap(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );;

	//Background
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, BackgroundTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(-0, -0);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(-0, 600);		//Top left
			glTexCoord2f(1,0); glVertex2f(800, 600);	//Top right
			glTexCoord2f(1,1); glVertex2f(800, -0);		//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
/*****************************
--------- DRAW BUTTONS ---------
******************************/

//Draw Main Menu Button
void CGameMenu::DrawMainMenuButton(void)
{
	MenuButtonAnimation();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	glPushMatrix ();
	glTranslatef(0.0f, 35.0f, 0.0f);
	//Choose Character Button
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MainMenuTexture[0].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(300 + Menu_Animation_x, 180);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(300 + Menu_Animation_x, 230);	//Top left
			glTexCoord2f(1,0); glVertex2f(500 + Menu_Animation_x, 230);	//Top right
			glTexCoord2f(1,1); glVertex2f(500 + Menu_Animation_x, 180);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Load button
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MainMenuTexture[1].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(350 + Menu_Animation_x, 240);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(350 + Menu_Animation_x, 290);	//Top left
			glTexCoord2f(1,0); glVertex2f(450 + Menu_Animation_x, 290);	//Top right
			glTexCoord2f(1,1); glVertex2f(450 + Menu_Animation_x, 240);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Setting button
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MainMenuTexture[2].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(325 + Menu_Animation_x, 300);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(325 + Menu_Animation_x, 350);	//Top left
			glTexCoord2f(1,0); glVertex2f(475 + Menu_Animation_x, 350);	//Top right
			glTexCoord2f(1,1); glVertex2f(475 + Menu_Animation_x, 300);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Achievement button
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MainMenuTexture[3].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(300 + Menu_Animation_x, 360);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(300 + Menu_Animation_x, 410);	//Top left
			glTexCoord2f(1,0); glVertex2f(500 + Menu_Animation_x, 410);	//Top right
			glTexCoord2f(1,1); glVertex2f(500 + Menu_Animation_x, 360);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Exit button
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, MainMenuTexture[5].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(350 + Menu_Animation_x, 420);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(350 + Menu_Animation_x, 470);	//Top left
			glTexCoord2f(1,0); glVertex2f(450 + Menu_Animation_x, 470);	//Top right
			glTexCoord2f(1,1); glVertex2f(450 + Menu_Animation_x, 420);	//Bottom right
		glEnd();
	glPopMatrix ();

	glPopMatrix ();
	////Credit button
	//glPushMatrix ();
	//	glColor3f(1.0f, 1.0f, 1.0f);
	//	glBindTexture(GL_TEXTURE_2D, MainMenuTexture[4].texID);
	//	glBegin( GL_QUADS );
	//		glTexCoord2f(0,1); glVertex2f(325 + Menu_Animation_x, 420);	//Bottom left
	//		glTexCoord2f(0,0); glVertex2f(325 + Menu_Animation_x, 470);	//Top left
	//		glTexCoord2f(1,0); glVertex2f(475 + Menu_Animation_x, 470);	//Top right
	//		glTexCoord2f(1,1); glVertex2f(475 + Menu_Animation_x, 420);	//Bottom right
	//	glEnd();
	//glPopMatrix ();

	////Exit button
	//glPushMatrix ();
	//	glColor3f(1.0f, 1.0f, 1.0f);
	//	glBindTexture(GL_TEXTURE_2D, MainMenuTexture[5].texID);
	//	glBegin( GL_QUADS );
	//		glTexCoord2f(0,1); glVertex2f(350 + Menu_Animation_x, 480);	//Bottom left
	//		glTexCoord2f(0,0); glVertex2f(350 + Menu_Animation_x, 530);	//Top left
	//		glTexCoord2f(1,0); glVertex2f(450 + Menu_Animation_x, 530);	//Top right
	//		glTexCoord2f(1,1); glVertex2f(450 + Menu_Animation_x, 480);	//Bottom right
	//	glEnd();
	//glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}

//Draw choose Character Button
void CGameMenu::DrawChooseCharacterButton(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Sword And Shield
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);

		if(CharacterButtonType == 0)
		{
			glBindTexture(GL_TEXTURE_2D, CharacterButtonTexture[3].texID);
		}
		else
		{
			glBindTexture(GL_TEXTURE_2D, CharacterButtonTexture[0].texID);
		}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(50, 300);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(50, 500);		//Top left
			glTexCoord2f(1,0); glVertex2f(250, 500);	//Top right
			glTexCoord2f(1,1); glVertex2f(250, 300);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Great Sword
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		
		if(CharacterButtonType == 1)
		{
			glBindTexture(GL_TEXTURE_2D, CharacterButtonTexture[4].texID);
		}
		else
		{
			glBindTexture(GL_TEXTURE_2D, CharacterButtonTexture[1].texID);
		}
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(300, 300);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(300, 500);	//Top left
			glTexCoord2f(1,0); glVertex2f(500, 500);	//Top right
			glTexCoord2f(1,1); glVertex2f(500, 300);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Dual Sword
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);

		if(CharacterButtonType == 2)
		{
			glBindTexture(GL_TEXTURE_2D, CharacterButtonTexture[5].texID);
		}
		else
		{
			glBindTexture(GL_TEXTURE_2D, CharacterButtonTexture[2].texID);
		}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(550, 300);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(550, 500);	//Top left
			glTexCoord2f(1,0); glVertex2f(750, 500);	//Top right
			glTexCoord2f(1,1); glVertex2f(750, 300);	//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}

//Draw setting button
void CGameMenu::DrawSettingButton(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Title - Sounds
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, SettingsMenuTexture[1].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(100, 280);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(100, 380);		//Top left
			glTexCoord2f(1,0); glVertex2f(300, 380);	//Top right
			glTexCoord2f(1,1); glVertex2f(300, 280);		//Bottom right
		glEnd();
	glPopMatrix ();

	//On and Off 
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		if(BGM == true)
		{
			glBindTexture(GL_TEXTURE_2D, SettingsMenuTexture[2].texID);
		}
		else if(BGM == false)
		{
			glBindTexture(GL_TEXTURE_2D, SettingsMenuTexture[3].texID);
		}
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(350, 300);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(350, 380);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 380);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 300);	//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
//Draw Lobby Button
void CGameMenu::DrawLobbyButton(void)
{
	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	glPushMatrix ();
	glTranslatef(0.0f, 0.0f, 0.0f);

	//Sword And Shield
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);

		if(LobbyButtonType == CGameMenu::SWORD_AND_SHIELD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[SWORD_AND_SHIELD_SHOP_BUTTON+3].texID);
		}
		else if(LobbyButtonType == CGameMenu::GREAT_SWORD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[GREAT_SWORD_SHOP_BUTTON-1].texID);
		}		
		else if(LobbyButtonType == CGameMenu::DUAL_SWORD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[DUAL_SWORD_SHOP_BUTTON-1].texID);
		}
		else if(LobbyButtonType == CGameMenu::POTION_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[POTION_BUTTON-1].texID);
		}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(200, 450);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(200, 550);	//Top left
			glTexCoord2f(1,0); glVertex2f(400, 550);	//Top right
			glTexCoord2f(1,1); glVertex2f(400, 450);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Great Sword
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);
		
		if(LobbyButtonType == CGameMenu::SWORD_AND_SHIELD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[SWORD_AND_SHIELD_SHOP_BUTTON+1].texID);
		}
		else if(LobbyButtonType == CGameMenu::GREAT_SWORD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[GREAT_SWORD_SHOP_BUTTON+1].texID);
		}		
		else if(LobbyButtonType == CGameMenu::DUAL_SWORD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[DUAL_SWORD_SHOP_BUTTON+1].texID);
		}
		else if(LobbyButtonType == CGameMenu::POTION_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[POTION_BUTTON-3].texID);
		}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(400, 450);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(400, 550);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 550);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 450);	//Bottom right
		glEnd();
	glPopMatrix ();

	// Dual Sword //
	glPushMatrix ();
		glColor3f(1.0f, 1.0f, 1.0f);

		if(LobbyButtonType == CGameMenu::SWORD_AND_SHIELD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[SWORD_AND_SHIELD_SHOP_BUTTON].texID);
		}
		else if(LobbyButtonType == CGameMenu::GREAT_SWORD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[GREAT_SWORD_SHOP_BUTTON].texID);
		}		
		else if(LobbyButtonType == CGameMenu::DUAL_SWORD_SHOP_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[DUAL_SWORD_SHOP_BUTTON].texID);
		}
		else if(LobbyButtonType == CGameMenu::POTION_BUTTON)
		{
			glBindTexture(GL_TEXTURE_2D, LobbyTexture[POTION_BUTTON].texID);
		}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(300, 450);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(300, 550);	//Top left
			glTexCoord2f(1,0); glVertex2f(500, 550);	//Top right
			glTexCoord2f(1,1); glVertex2f(500, 450);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Left arrow
	glPushMatrix ();
		glColor3f( 1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[5].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(200, 560);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(200, 590);	//Top left
			glTexCoord2f(1,0); glVertex2f(250, 590);	//Top right
			glTexCoord2f(1,1); glVertex2f(250, 560);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Right arrow
	glPushMatrix ();
		glColor3f( 1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[6].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(550, 560);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(550, 590);	//Top left
			glTexCoord2f(1,0); glVertex2f(600, 590);	//Top right
			glTexCoord2f(1,1); glVertex2f(600, 560);	//Bottom right
		glEnd();
	glPopMatrix ();

	if(LobbyButtonType == CGameMenu::POTION_BUTTON)
	{
	}
	else
	{
		glPushMatrix ();
			glColor3f( 1.0f, 1.0f, 1.0f);
			if(CheckWeapon == false)
			{
				glBindTexture(GL_TEXTURE_2D, LobbyTexture[8].texID);//buy
				glBegin( GL_QUADS );
					glTexCoord2f(0,1); glVertex2f(375, 560);	//Bottom left
					glTexCoord2f(0,0); glVertex2f(375, 590);	//Top left
					glTexCoord2f(1,0); glVertex2f(425, 590);	//Top right
					glTexCoord2f(1,1); glVertex2f(425, 560);	//Bottom right
				glEnd();
			}
			else if (CheckWeapon == true)
			{
				glBindTexture(GL_TEXTURE_2D, LobbyTexture[7].texID);//upgrade
					glBegin( GL_QUADS );
						glTexCoord2f(0,1); glVertex2f(350, 560);	//Bottom left
						glTexCoord2f(0,0); glVertex2f(350, 590);	//Top left
						glTexCoord2f(1,0); glVertex2f(450, 590);	//Top right
						glTexCoord2f(1,1); glVertex2f(450, 560);	//Bottom right
					glEnd();			
			}
		glPopMatrix ();
	}

	//Mission
	glPushMatrix ();
		glColor3f( 1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, LobbyTexture[9].texID);
		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(620, 30);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(620, 130);	//Top left
			glTexCoord2f(1,0); glVertex2f(720, 130);	//Top right
			glTexCoord2f(1,1); glVertex2f(720, 30);	//Bottom right
		glEnd();
	glPopMatrix ();

	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
//Draw Mission Button
void CGameMenu::DrawMissonButton(void)
{
	MenuButtonAnimation();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	//Mission 1
	glPushMatrix ();

	if(MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[4].texID);
	}
	else if(MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[7].texID);
	}
	else if(MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[13].texID);
	}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(50, 225 + PickCharWeapon_Animation_x);		//Bottom left
			glTexCoord2f(0,0); glVertex2f(50, 425 + PickCharWeapon_Animation_x);		//Top left
			glTexCoord2f(1,0); glVertex2f(250, 425 + PickCharWeapon_Animation_x);	//Top right
			glTexCoord2f(1,1); glVertex2f(250, 225 + PickCharWeapon_Animation_x);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Mission 2
	glPushMatrix ();
		
	if(MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[5].texID);
	}
	else if(MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[8].texID);
	}
	else if(MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[14].texID);
	}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(300, 225 + PickCharWeapon_Animation_x);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(300, 425 + PickCharWeapon_Animation_x);	//Top left
			glTexCoord2f(1,0); glVertex2f(500, 425 + PickCharWeapon_Animation_x);	//Top right
			glTexCoord2f(1,1); glVertex2f(500, 225 + PickCharWeapon_Animation_x);	//Bottom right
		glEnd();
	glPopMatrix ();

	//Mission 3
	glPushMatrix ();
		
	if(MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[6].texID);
	}
	else if(MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[9].texID);
	}
	else if(MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
	{
		glBindTexture(GL_TEXTURE_2D, MissionTexture[15].texID);
	}

		glBegin( GL_QUADS );
			glTexCoord2f(0,1); glVertex2f(550, 225 + PickCharWeapon_Animation_x);	//Bottom left
			glTexCoord2f(0,0); glVertex2f(550, 425 + PickCharWeapon_Animation_x);	//Top left
			glTexCoord2f(1,0); glVertex2f(750, 425 + PickCharWeapon_Animation_x);	//Top right
			glTexCoord2f(1,1); glVertex2f(750, 225 + PickCharWeapon_Animation_x);	//Bottom right
		glEnd();
	glPopMatrix ();

	glDisable(GL_BLEND);		//Enable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
// ******* DRAW ARROW KEY ********* //
void CGameMenu::DrawMenuKey(void)
{
	ArrowCheckButton();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	glPushMatrix ();
		glColor3f( 1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, ButtonTexture[0].texID);
		glBegin( GL_QUADS );
				glTexCoord2f(0,1); glVertex2f(230.0f + ArrowKey_x, 207.0f + ArrowKey_y);	//Bottom left
				glTexCoord2f(0,0); glVertex2f(230.0f + ArrowKey_x, 267.0f + ArrowKey_y);	//Top left
				glTexCoord2f(1,0); glVertex2f(270.0f + ArrowKey_x, 267.0f + ArrowKey_y);	//Top right
				glTexCoord2f(1,1); glVertex2f(270.0f + ArrowKey_x, 207.0f + ArrowKey_y);	//Bottom right
		glEnd();
	glPopMatrix ();
	
	glDisable (GL_BLEND);		//Disable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}


//Key for mission menu
void CGameMenu::DrawCharKey(void)
{
	ArrowCheckButton();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	glPushMatrix ();
		glColor3f( 1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, ButtonTexture[1].texID);
		glBegin( GL_QUADS );
				glTexCoord2f(0,1); glVertex2f(230.0f + ArrowKey_x, 180.0f + ArrowKey_y);	//Bottom left
				glTexCoord2f(0,0); glVertex2f(230.0f + ArrowKey_x, 230.0f + ArrowKey_y);	//Top left
				glTexCoord2f(1,0); glVertex2f(280.0f + ArrowKey_x, 230.0f + ArrowKey_y);	//Top right
				glTexCoord2f(1,1); glVertex2f(280.0f + ArrowKey_x, 180.0f + ArrowKey_y);	//Bottom right
		glEnd();
	glPopMatrix ();
	
	glDisable (GL_BLEND);		//Disable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}

//Key for setting menu
void CGameMenu::DrawSettingKey(void)
{
	ArrowCheckButton();

	glEnable(GL_TEXTURE_2D);	//Enable texture
	glEnable(GL_BLEND);			//Enable blend
	glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );

	glPushMatrix ();
		glColor3f( 1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, ButtonTexture[1].texID);
		glBegin( GL_QUADS );
				glTexCoord2f(0,1); glVertex2f(370.0f + ArrowKey_x, 180.0f + ArrowKey_y);	//Bottom left
				glTexCoord2f(0,0); glVertex2f(370.0f + ArrowKey_x, 230.0f + ArrowKey_y);	//Top left
				glTexCoord2f(1,0); glVertex2f(430.0f + ArrowKey_x, 230.0f + ArrowKey_y);	//Top right
				glTexCoord2f(1,1); glVertex2f(430.0f + ArrowKey_x, 180.0f + ArrowKey_y);	//Bottom right
		glEnd();
	glPopMatrix ();
	
	glDisable (GL_BLEND);		//Disable blend
	glDisable (GL_TEXTURE_2D);	//Disable texture
}
/*****************************
--------- FUNCTIONS ---------
******************************/

//Check Arrow position
void CGameMenu::ArrowCheckButton(void)
{
	//Draw out the position of the arrow key at main menu
	if(MenuType == CGameMenu::MAIN_MENU)
	{
		//Reset Arrow key position to original position
		ArrowKey_x = 0;
		ArrowKey_y = 100;

		for(int i = 0; i <= 5; i ++)
		{
			if(MainMenuButtonType == i)
			{
				ArrowKey_y = 0 + i*60;
			}
		}
	}

	else if(MenuType == CGameMenu::MISSION_MENU)
	{
		//Reset Arrow key position to original position
		ArrowKey_x = -100;
		ArrowKey_y = 250;

		for(int i = 0; i <= 8; i ++)
		{
			if(MissionButtonType == i)
			{
				if(MissionButtonType >= 0 && MissionButtonType <= 2)
				{
					ArrowKey_x = -100 + i*250;
					ArrowKey_y = 250;
				}
				else if(MissionButtonType >= 3 && MissionButtonType <= 5)
				{
					ArrowKey_x = -100 + (i-3)*250;
					ArrowKey_y = 250;
				}
				else if(MissionButtonType >= 6 && MissionButtonType <= 8)
				{
					ArrowKey_x = -100 + (i-6)*250;
					ArrowKey_y = 250;
				}
			}
		}
	}
	else if(MenuType == CGameMenu::SETTING_MENU)
	{
		//Reset Arrow key position to original position
		ArrowKey_x = 0;
		ArrowKey_y = 200;

		for(int i = 0; i <= 1; i ++)
		{
			if(SettingButtonType == i)
			{
				ArrowKey_x = 0 + i*150;
			}
		}
	}
}

//Up button
void CGameMenu::ButtonUp(void)
{
	if(MenuType == CGameMenu::MAIN_MENU)
	{
		//Change button type
		MainMenuButtonType -= 1;

		//If exceeded minimum amount of button
		if (MainMenuButtonType <= -1)
		{
			MainMenuButtonType = 4;	//Return to bottom button 
		}
	}

	else if(MenuType == CGameMenu::MISSION_MENU)
	{
		MissionDifficultyButtonType -= 1;

		//If exceeded minimum amount of button
		if (MissionDifficultyButtonType <= -1)
		{
			MissionDifficultyButtonType = 2;	//Return to bottom button 
		}

		if (MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
		{
			MissionButtonType = 0;
		}
		else if (MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
		{
			MissionButtonType = 3;
		}
		else if (MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
		{
			MissionButtonType = 6;
		}
	}
}

//Down button
void CGameMenu::ButtonDown(void)
{
	if(MenuType == CGameMenu::MAIN_MENU)
	{
		//Change button type
		MainMenuButtonType += 1;

		//If exceeded max amount of button
		if (MainMenuButtonType >= 5)
		{
			MainMenuButtonType = 0;	//Return to top button 
		}
	}
	else if(MenuType == CGameMenu::MISSION_MENU)
	{
		//Change button type
		MissionDifficultyButtonType += 1;

		//If exceeded max amount of button
		if (MissionDifficultyButtonType >= 3)
		{
			MissionDifficultyButtonType = 0;	//Return to top button 
		}

		if (MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
		{
			MissionButtonType = 0;
		}
		else if (MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
		{
			MissionButtonType = 3;
		}
		else if (MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
		{
			MissionButtonType = 6;
		}
	}
}

//Left button
void CGameMenu::ButtonLeft(void)
{
	if(MenuType == CGameMenu::CHARACTER_MENU)
	{
		//Change button type
		CharacterButtonType -= 1;

		//If exceeded max amount of button
		if (CharacterButtonType <= -1)
		{
			CharacterButtonType = 2;	//Return to most right button
		}
	}
	else if(MenuType == CGameMenu::SETTING_MENU)
	{
		//Change button type
		SettingButtonType -= 1;

		//If exceeded max amount of button
		if (SettingButtonType <= -1)
		{
			SettingButtonType = 1;	//Return to most right button
		}
	}

	else if(MenuType == CGameMenu::LOBBY_MENU)
	{
		//Change button type
		LobbyButtonType -= 1;

		//If exceeded max amount of button
		if (LobbyButtonType <= -1)
		{
			LobbyButtonType = 3;	//Return to most right button
		}
	}

	else if(MenuType == CGameMenu::MISSION_MENU)
	{
		//Change button type
		MissionButtonType -= 1;

		if (MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
		{
			//MissionButtonType = 0;

			//If exceeded max amount of button
			if (MissionButtonType <= -1)
			{
				MissionButtonType = 2;	//Return to most right button
			}
		}
		else if(MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
		{
			//MissionButtonType = 3;

			//If exceeded max amount of button
			if (MissionButtonType <= 2)
			{
				MissionButtonType = 5;	//Return to most right button
			}
		}
		else if (MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
		{
			//MissionButtonType = 6;

			//If exceeded max amount of button
			if (MissionButtonType <= 5)
			{
				MissionButtonType = 8;	//Return to most right button
			}
		}
	}
}

//Right button
void CGameMenu::ButtonRight(void)
{
	if(MenuType == CGameMenu::CHARACTER_MENU)
	{
		//Change button type
		CharacterButtonType += 1;

		//If exceeded max amount of button
		if (CharacterButtonType >= 3)
		{
			CharacterButtonType = 0;	//Return to most left button
		}
	}

	else if(MenuType == CGameMenu::SETTING_MENU)
	{
		SettingButtonType += 1;

		if (SettingButtonType >= 2)
		{
			SettingButtonType = 0;
		}
	}

	else if(MenuType == CGameMenu::LOBBY_MENU)
	{
		//Change button type
		LobbyButtonType += 1;

		//If exceeded max amount of button
		if (LobbyButtonType >= 4)
		{
			LobbyButtonType = 0;	//Return to most left button
		}
	}

	else if(MenuType == CGameMenu::MISSION_MENU)
	{
		//Change button type
		MissionButtonType += 1;

		if (MissionDifficultyButtonType == CGameMenu::EASY_MISSION)
		{
			//If exceeded max amount of button
			if (MissionButtonType >= 3)
			{
				MissionButtonType = 0;	//Return to most left button
			}
		}
		else if (MissionDifficultyButtonType == CGameMenu::NORMAL_MISSION)
		{
			//If exceeded max amount of button
			if (MissionButtonType >= 6)
			{
				MissionButtonType = 3;	//Return to most left button
			}
		}
		else if (MissionDifficultyButtonType == CGameMenu::HARD_MISSION)
		{
			//If exceeded max amount of button
			if (MissionButtonType >= 9)
			{
				MissionButtonType = 6;	//Return to most left button
			}
		}
	}
}

//Toggle enter
void CGameMenu::CheckEnterButton(void)
{
	if (MenuType == CGameMenu::MAIN_MENU)
	{
		//Pick character or Load button
		if (MainMenuButtonType == CGameMenu::CHARACTER_BUTTON || MainMenuButtonType == CGameMenu::LOAD_BUTTON)
		{
			MenuType = CGameMenu::SPLASH_SCREEN_MENU;
		}
		//Setting button
		else if(MainMenuButtonType == CGameMenu::SETTING_BUTTON)
		{
			MenuType = CGameMenu::SETTING_MENU;
		}
		//Achievement button
		else if(MainMenuButtonType == CGameMenu::ACHIEVEMENT_BUTTON)
		{
			MenuType = CGameMenu::ACHIEVEMENT_MENU;
		}
		//Credits button
		/*else if(MainMenuButtonType == CGameMenu::CREDITS_BUTTON)
		{
			MenuType = CGameMenu::CREDIT_MENU;
		}*/

		//Exit button
		else if(MainMenuButtonType == CGameMenu::EXIT_BUTTON)
		{
			glutLeaveMainLoop();
		}
	}

	else if (MenuType == CGameMenu::CHARACTER_MENU)
	{
		if (CharacterButtonType == CGameMenu::SWORD_AND_SHIELD_BUTTON	||
			CharacterButtonType == CGameMenu::GREAT_SWORD_BUTTON		||
			CharacterButtonType == CGameMenu::DUAL_SWORD_BUTTON			)
		{
			MenuType = CGameMenu::LOBBY_MENU;
		}
	}

	else if(MenuType == CGameMenu::SETTING_MENU)
	{
		if (SettingButtonType == CGameMenu::BGM_ON_BUTTON)
		{
			BGM = true;
		}
		else if(SettingButtonType == CGameMenu::BGM_OFF_BUTTON)
		{
			BGM = false;
		}
	}
	else if(MenuType == CGameMenu::LOBBY_MENU)
	{
		if (LobbyButtonType == CGameMenu::SWORD_AND_SHIELD_SHOP_BUTTON)
		{
			//Upgrade sword and shield
		}
		else if (LobbyButtonType == CGameMenu::GREAT_SWORD_SHOP_BUTTON)
		{
			//Upgrade Great sword
		}
		else if (LobbyButtonType == CGameMenu::DUAL_SWORD_SHOP_BUTTON)
		{
			//Upgrade Dual sword
		}
		else if (LobbyButtonType == CGameMenu::POTION_BUTTON)
		{
			//Buy potion
		}
	}	
}

//Toggle key
void CGameMenu::CheckKeys(void)
{
	if (MenuType == CGameMenu::LOBBY_MENU)
	{
		MenuType = CGameMenu::MISSION_MENU;
	}
}

//Animation
void CGameMenu::MenuButtonAnimation(void)
{
	if (VibrateAnimation == false)
	{
		//MAIN MENU
		if(MenuType == CGameMenu::MAIN_MENU ||
			MenuType == CGameMenu::MISSION_MENU)
		{
			Menu_Animation_x += (20 * FrameTime);

			if (Menu_Animation_x >= 5)
			{
				VibrateAnimation = true;
			}
		}

		//PICK CHARACTER MENU
		if(MenuType == CGameMenu::CHARACTER_MENU)
		{
			PickChar_Animation_x += (100 * FrameTime);
			
			if (PickChar_Animation_x >= 2)
			{
				VibrateAnimation = true;
			}
		}
	}
	else if(VibrateAnimation == true)
	{
		//MAIN MENU
		if(MenuType == CGameMenu::MAIN_MENU ||
			MenuType == CGameMenu::MISSION_MENU)
		{
			Menu_Animation_x -= (20 * FrameTime);
		
			if (Menu_Animation_x <= -5)
			{
				VibrateAnimation = false;
			}
		}

		//PICK CHARACTER MENU
		if(MenuType == CGameMenu::CHARACTER_MENU)
		{
			PickChar_Animation_x -= (100 * FrameTime);
			
			if (PickChar_Animation_x <= -2)
			{
				VibrateAnimation = false;
			}
		}
	}

	//Weapon name
	if (VibrateAnimationTwo == false)
	{
		//PICK CHARACTER MENU
		if(MenuType == CGameMenu::SPLASH_SCREEN_MENU ||
			MenuType == CGameMenu::CHARACTER_MENU ||
			MenuType == CGameMenu::MISSION_MENU	)
		{
			PickCharWeapon_Animation_x += (10 * FrameTime);
			
			if (PickCharWeapon_Animation_x >= 5)
			{
				VibrateAnimationTwo = true;
			}
		}
	}
	else if(VibrateAnimationTwo == true)
	{
		PickCharWeapon_Animation_x -= (10 * FrameTime);
			
		if(MenuType == CGameMenu::SPLASH_SCREEN_MENU ||
			MenuType == CGameMenu::CHARACTER_MENU ||
			MenuType == CGameMenu::MISSION_MENU	)
		{
			if (PickCharWeapon_Animation_x <= -5)
			{
				VibrateAnimationTwo = false;
			}
		}
	}
}